using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace Xfinity.Systems
{
    public static class StartupInitialisation
    {
        public static void RunStartupMethods()
        {
            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                foreach (Type type in assembly.GetTypes())
                {
                    foreach (MethodInfo methodInfo in type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
                    {
                        object[] attributes = methodInfo.GetCustomAttributes(typeof(RunOnStartupAttribute), true);
                        if (attributes.Length > 0)
                        {
                            methodInfo.Invoke(null, null);
                        }
                    }
                }
            }
        }
    }
}
